﻿#pragma once

#include "Render/Material/RenderMaterialType.h"
#include "Render/VulkanMemory/Buffers.h"

class CRenderShader;
class CVulkanTexture2D;
class CVulkanTextureCube;

struct CVulkanPipeline
{
    vk::DescriptorSetLayout DescriptorSetLayout;
    vk::PipelineLayout PipelineLayout;
    vk::Pipeline Pipeline;
    ERenderMaterialType Type = ERenderMaterialType::Opaque;
};

struct CVulkanMaterialParameter
{
    TVector<std::shared_ptr<CVulkanTexture2D>> Texture2Ds;
    TVector<std::shared_ptr<CVulkanTextureCube>> TextureCubes;
    CVulkanUniformBuffer FloatParameterBuffer;
};

struct CVulkanMaterial
{
public:

    //所需的一些对象，用于生成描述符
    std::shared_ptr<CVulkanMaterialParameter> Parameters;
    vk::DescriptorSet DescriptorSet;

    // ERenderMaterialType Type = ERenderMaterialType::Opaque;
    // vk::DescriptorSetLayout DescriptorSetLayout;
    // vk::PipelineLayout PipelineLayout;
    // vk::Pipeline Pipeline;
    std::shared_ptr<CVulkanPipeline> Pipeline;

    bool CanDefferRender();
    bool CanUnlitRender(); 

    //统计描述符数量
    void PrepareSelfRecord();

    //由于描述符池自动重置，所以每帧都要重新分配描述符
    void MakeSureDescriptorSetAvaliable();

protected:
    //上一次更新时帧
    //用于判断是否需要更新描述符
    //int32_t LastFrame= -1;

};